package util;

import java.awt.Toolkit;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;

public class Util 
{

    private Util() 
    {
    }

    public static void quit() 
    {
        System.exit(0);
    }

    public static void consoleSysCapacity() 
    {
        console("[Engine]  Starting Memory:   " + getStartingMemory()/1048576f + " MB");
//        console("[Engine]  Max Memory:        " + getMaxMemory()/1048576f + " MB");
    }
    
    public static String formatFloat(float input)
    {
        return String.format("%.4f", input);
    }

    public static int getScreenW() 
    {
        return Toolkit.getDefaultToolkit().getScreenSize().width;
    }

    public static int getScreenH() 
    {
        return Toolkit.getDefaultToolkit().getScreenSize().height;
    }

    public static long getMaxMemory() 
    {
        return Runtime.getRuntime().maxMemory();
    }

    public static long getStartingMemory() 
    {
        return Runtime.getRuntime().totalMemory();
    }

    public static IntBuffer getIntBuf(int[] arr) 
    {
        return (IntBuffer) (BufferUtils.createIntBuffer(arr.length).put(arr).flip());
    }

    public static ByteBuffer getByteBuf(byte[] arr) 
    {
        return (ByteBuffer) (BufferUtils.createByteBuffer(arr.length).put(arr).flip());
    }

    public static FloatBuffer getFloatBuf(float[] arr) 
    {
        return (FloatBuffer) (BufferUtils.createFloatBuffer(arr.length).put(arr).flip());
    }

    public static void console() 
    {
        System.out.println();
    }

    public static void console(boolean str) 
    {
        System.out.println(str);
    }

    public static void console(byte str) 
    {
        System.out.println(str);
    }

    public static void console(int str) 
    {
        System.out.println(str);
    }

    public static void console(long str) 
    {
        System.out.println(str);
    }

    public static void console(float str) 
    {
        System.out.println(str);
    }

    public static void console(double str) 
    {
        System.out.println(str);
    }

    public static void console(String str) 
    {
        System.out.println(str);
    }
    
    public static void console(Exception e) 
    {
        System.out.println(e);
    }

}
